#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int dfs(vector<vector<int>> &gh, int u, vector<int> &path, int emin, int emax)
{
        for(int v = emin; v <= emax; v++){
                if(gh[u][v]){
                        gh[u][v]--;
                        gh[v][u]--;
                        dfs(gh, v, path, emin, emax);
                }
        }
        path.push_back(u);
        return 0;
}

int main()
{
        int n;
        cin>>n;
        vector<vector<int>> gh(600, vector<int>(600, 0));
        vector<int> degree(600, 0);
        int emin = INT32_MAX, emax = INT32_MIN;
        for(int i = 0; i < n; i++){
                int u, v;
                cin >> u >> v;
                gh[u][v]++;
                gh[v][u]++;
                degree[v]++;
                degree[u]++;
                emin = min({emin, u, v});
                emax = max({emax, u, v});
        }

        int start = emin;
        vector<int> path;
        for(int i = emin; i <= emax; i++){
                if(degree[i]%2 == 1){
                        start = i;
                        break;
                }
        }
        dfs(gh, start, path, emin, emax);
        reverse(path.begin(), path.end());
        for(auto u : path){
                cout << u << endl;
        }
        return 0;
}